package com.xgq.drink.mapper;

import com.xgq.drink.entity.FavoriteProduct;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 用户收藏表 Mapper 接口
 * </p>
 *
 * @author xgq
 * @since 2025-03-02
 */
public interface FavoriteProductMapper extends BaseMapper<FavoriteProduct> {
    @Select("SELECT COUNT(*) FROM favorite_product WHERE user_id = #{userId} AND product_id = #{productId} AND is_del = 0")
    int selectCountByUserIdAndProductId(Long userId, Long productId);
    @Update("UPDATE favorite_product SET is_del = 1 WHERE favorite_product_id = #{favoriteProductId} AND user_id = #{userId}")
    int logicDeleteByUserIdAndFavoriteProductId(Long userId, Long favoriteProductId);
}
